package com.openbravo.pos.panels.link.model;

import com.openbravo.bean.sales.QuickProductExt;
import com.openbravo.bean.viewbean.Product_V;
import com.openbravo.format.Formats;
import com.openbravo.pos.base.AppLocal;

import cn.ekuma.data.ui.swing.AbstractDTOTableModel;


public class QuickProductExtTableModel extends AbstractDTOTableModel<QuickProductExt> {
	

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		QuickProductExt obj=objs.get(rowIndex);
		Product_V inculdProduct = obj.getProd();
        switch(columnIndex){
            case 0:
                return inculdProduct.getM_sRef();
            case 1:
                return inculdProduct.getM_sCode();
            case 2:
                return inculdProduct.getM_sName();
            case 3:
                return Formats.CURRENCY.formatValue(inculdProduct.getM_dPriceSell());
            case 4:    
            	return Formats.CURRENCY.formatValue(inculdProduct.getM_dCustomerPrice());
            case 5:
           	    return inculdProduct.getM_sManufacturer();
            case 6:
           	    return inculdProduct.getM_origin();
            case 7:
           	    return inculdProduct.getM_iDurability();
            case 8:
           	    return inculdProduct.isM_bCom()?"Y":" ";
            case 9:
           	    return inculdProduct.getM_quantity();
            case 10:
            	return getTypeLocalName(obj.getType());
            case 11:
            	return Formats.TIMESTAMP.formatValue(obj.getCurDate());
            case 12:
            	return obj.getUnit();
            }
        return null;
	}

	@Override
	public String[] getColumnNames() {
		return new String[] {
        		AppLocal.getIntString("label.prodref"),
        		AppLocal.getIntString("label.prodbarcode"),
                AppLocal.getIntString("label.prodname"),
                AppLocal.getIntString("label.prodpricesell"),
                AppLocal.getIntString("label.baseCustomerPrice"),
                AppLocal.getIntString("label.prodcut.m_sManufacturer"),
                AppLocal.getIntString("label.product.origin"),
                AppLocal.getIntString("label.product.m_iDurability"),
                AppLocal.getIntString("label.prodaux"),
                AppLocal.getIntString("label.product.quantity"),
                AppLocal.getIntString("label.QuickProduct.type"),
                AppLocal.getIntString("label.date"),
                AppLocal.getIntString("label.units")
                };
	}
	
	public static String getTypeLocalName(int type){
		switch(type){
		case 1:
			return AppLocal.getIntString("QuickProduct.TYPE_MovementFrom");
		case 2:
			return AppLocal.getIntString("QuickProduct.TYPE_MovementTo");
		case 3:
			return AppLocal.getIntString("QuickProduct.TYPE_VendorIn");
		case 4:
			return AppLocal.getIntString("QuickProduct.TYPE_VendorOut");
		case 5:
			return AppLocal.getIntString("QuickProduct.TYPE_OutOfStock");
		case 6:
			return AppLocal.getIntString("QuickProduct.TYPE_BeDamaged");
		case 7:
			return AppLocal.getIntString("QuickProduct.TYPE_BeOverdue");
		case 8:
			return AppLocal.getIntString("QuickProduct.TYPE_Overdue");
		case 9:
			return AppLocal.getIntString("QuickProduct.TYPE_Unsalable");			
			
		}
		return "";
	}

}
